﻿using System;

namespace FlickrXplorer.Web.Plugin.Exceptions
{
    /// <summary>
    /// Thrown when a plugin has not hooked any of the events
    /// available in the <see cref="FlickrXplorer.Web.Plugin.FlickrXplorerPlugin" text="FlickrXplorerPlugin" />.
    /// 
    /// </summary>                                                                                              
    public class PluginHasNoEventHandlersException : FlickrXplorerPluginException
    {
        /// <summary>
        /// Creates a new <see cref="PluginHasNoEventHandlersException" text="PluginHasNoEventHandlersException" />
        /// instance.
        /// </summary>
        /// <param name="plugin">A reference to the plugin has no event
        ///                      handlers.</param>                                                                                          
        public PluginHasNoEventHandlersException(FlickrXplorerPlugin plugin)
            : base(plugin, GetMessage(plugin))
        { 
        }

        private static string GetMessage(FlickrXplorerPlugin plugin)
        {
            return String.Format("The plugin called '{0}' of type '{1}' has no event handlers defined. Please define at least one event handler in order to run this plugin.",
                                 plugin.Name,
                                 plugin.GetType().FullName);
        }
    }
}